<?php 
    if(!empty($listtin)){
?>
    <?php 
        $dem = 1;
        foreach($listtin as $val){
    ?>
        <div class="row-fluid">
            <div class="box-bar-post<?php if($dem == count($listtin)) echo ' border-last';?>">
                <div class="bg-sitebar">
                    <p class="text-center"><?php echo $val['name'.LANGUAGE];?></p>
                </div>
                <div class="clear-content"></div>
                <div class="row-fluid">
                    <?php
                        if(!empty($val['list'][0]['Product']['name'])){
                    ?>
                    <div class="span8 box-new-list-content">
                        <a href="<?php echo DOMAIN.$val['list'][0]['Product']['link'];?>.html" title="<?php echo $val['list'][0]['Product']['name'];?>">
                            <img src="<?php echo DOMAIN;?>img/w250/<?php echo $val['list'][0]['Product']['images'];?>" class="span6 imgf" title="<?php echo $val['list'][0]['Product']['name'];?>" alt="<?php echo $val['list'][0]['Product']['name'];?>"/>
                        </a>
                        <a href="<?php echo DOMAIN.$val['list'][0]['Product']['link'];?>.html" title="<?php echo $val['list'][0]['Product']['name'];?>">
                            <h3><?php echo shortDesc($val['list'][0]['Product']['name'], 50);?></h3>
                        </a>
                        <div class="user-post-date">
                            <?php if(!empty($val['list'][0]['Product']['user_id'])){?>
                                <a href="#" type="User post">Admin</a> | Date
                            <?php }else{?>
                                <a href="<?php echo DOMAIN;?>profile" type="User post">Admin</a> | Date
                            <?php }?> 
                            <?php echo date('d-m-Y', strtotime($val['list'][0]['Product']['modified'])); ?>
                        </div>
                        <div class="view-cmt-like">
                            <img src="<?php echo DOMAIN;?>images/icon-view.png"/> <?php echo $val['list'][0]['Product']['view'];?>&nbsp;&nbsp;
                            <img src="<?php echo DOMAIN;?>images/icon-cmt.png"/> <?php echo $val['list'][0]['Product']['cmt'];?>&nbsp;&nbsp;
                            <img src="<?php echo DOMAIN;?>images/icon-like.png"/> <?php echo $val['list'][0]['Product']['like'];?>
                        </div>
                        <div class="shortdes">
                            <?php echo shortDesc($val['list'][0]['Product']['shortdes'], 100);?>
                        </div>
                        <div class="readmore">
                            <a href="<?php echo DOMAIN.$val['list'][0]['Product']['link'];?>.html" title="<?php echo $val['list'][0]['Product']['name'];?>">
                                Read more
                            </a>
                        </div>
                    </div>
                    <div class="span4 box-tin-khac">
                        <div class="title-bai-khac"><?php echo $titleDefinitions['cacbaikhac'];?></div>
                        <ul>
                            <?php
                                foreach($val['list'] as $value){
                                if($value['Product']['id'] != $val['list'][0]['Product']['id']){
                            ?>
                                <li>
                                    <i class="fa fa-caret-right pull-left"></i>
                                    <a href="<?php echo DOMAIN.$value['Product']['link'];?>.html" title="<?php echo $value['Product']['name'];?>">
                                        <h3 class="pull-left"><?php echo shortDesc($value['Product']['name'], 35);?></h3>
                                    </a>
                                </li>
                            <?php }}?>
                        </ul>
                        <div class="clear-main"></div>
                    </div>
                    <?php }?>
                </div>
                <div class="clear-content"></div>
            </div><!--end box-bar-post-->
        </div>
    <?php $dem ++;}?>
<?php 
    }else{
?>
    <div class="row-fluid">
        <div class="box-bar-post border-last">
            <div class="bg-sitebar">
                <p class=""><?php echo $cat['Catproduct']['name'.LANGUAGE];?></p>
            </div>
            <div class="clear-content"></div>
            <div class="row-fluid">
                <?php 
                    if(!empty($product)){
                        foreach($product as $value){
                ?>
                    <div class="box-new-list-content content-tin">
                        <a href="<?php echo DOMAIN.$value['Product']['link'];?>.html" title="<?php echo $value['Product']['name'];?>">
                            <img src="<?php echo DOMAIN;?>img/w250/<?php echo $value['Product']['images'];?>" class="span5 imgf" title="<?php echo $value['Product']['name'];?>" alt="<?php echo $value['Product']['name'];?>"/>
                        </a>
                        <a href="<?php echo DOMAIN.$value['Product']['link'];?>.html" title="<?php echo $value['Product']['name'];?>">
                            <h3><?php echo shortDesc($value['Product']['name'], 100);?></h3>
                        </a>
                        <div class="user-post-date">
                            <?php if(!empty($value['Product']['user_id'])){?>
                                <a href="#" type="User post">Admin</a> | Date
                            <?php }else{?>
                                <a href="<?php echo DOMAIN;?>profile" type="User post">Admin</a> | Date
                            <?php }?> 
                            <?php echo date('d-m-Y', strtotime($value['Product']['modified'])); ?>
                        </div>
                        <div class="view-cmt-like">
                            <img src="<?php echo DOMAIN;?>images/icon-view.png"/> <?php echo $value['Product']['view'];?>&nbsp;&nbsp;
                            <img src="<?php echo DOMAIN;?>images/icon-cmt.png"/> <?php echo $value['Product']['cmt'];?>&nbsp;&nbsp;
                            <img src="<?php echo DOMAIN;?>images/icon-like.png"/> <?php echo $value['Product']['like'];?>
                        </div>
                        <div class="shortdes">
                            <?php echo shortDesc($value['Product']['shortdes'], 300);?>
                        </div>
                        <div class="readmore">
                            <a href="<?php echo DOMAIN.$value['Product']['link'];?>.html" title="<?php echo $value['Product']['name'];?>">
                                Read more
                            </a>
                        </div>
                    </div>
                    <div class="clear-content" style="border-bottom: 1px solid #dedede;"></div>
                    <div class="clear-content"></div>
                <?php }}else echo 'Đang cập nhật !';?>
            </div>
        </div>
        <?php if($this->Paginator->numbers()){?>
            <div style="overflow: hidden;">
                <div class="pagination">
                    <?php
                        echo $this->Paginator->first('« Đầu');     
                        //echo $this->Paginator->prev('« Trước', null, null, array('class' => 'disabled')); 
                        echo $this->Paginator->numbers(
                            array(
                                'before' => null,
                                'after' => null,
                                
                    			'tag' => 'span',
                                'class' => 'number',
                    			'modulus' => '6',
                                'separator' => null,
                                'first' => 2,
                                'last' => 2,
                                'ellipsis' => '...',
                    			'currentClass' => 'current',
                                'currentTag' => null
                    		)
                        );
                        //echo $this->Paginator->next('Tiếp »'); 
                        echo $this->Paginator->last('Cuối »'); 
                        echo $this->Paginator->counter('Trang {:page}/{:pages}.');
                    ?>
                </div>
            </div>  
        <?php }?>
    </div>    
<?php }?>
<div class="clear-content"></div>